//
//  HYQTest1ViewController.m
//  HYQHUD_Example
//
//  Created by zhuxingjian on 2018/8/26.
//  Copyright © 2018年 zxj1989. All rights reserved.
//

#import "HYQTest1ViewController.h"
#import "HYQHUD.h"

typedef void(^progressBlock)(CGFloat progress);

@interface HYQTest1ViewController ()

@end

@implementation HYQTest1ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundColor:[UIColor redColor]];
    [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = CGRectMake(100, 300, 100, 100);
    [self.view addSubview:btn];
    
    self.view.backgroundColor = [UIColor whiteColor];
//    [self testProgressHUD];
}

- (void)btnAction:(UIButton *)btn
{
//    [HYQHUD showToast:@"加载成功加载成功加载成功加载成功加载成功加载成功加载成功加载成功加载成功加载成功"];
    [self testLoading];
}

- (void)testInViewHUD:(BOOL)enableTouch
{
    [HYQHUD showHUDInView:self.view enableTouch:enableTouch];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [HYQHUD hidHUDFromView:self.view];
    });
}

- (void)testGlobalHUD
{
    [HYQHUD showGlobalHUD];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [HYQHUD hidGlobalHUD];
    });
}

- (void)testProgressHUD
{
    NSProgress *progress = [NSProgress progressWithTotalUnitCount:100];
    [HYQHUD showHUDInView:self.view progress:progress title:@"正在上传。。。"];
    NSTimer *timer = [NSTimer timerWithTimeInterval:1 repeats:true block:^(NSTimer * _Nonnull timer) {
        progress.completedUnitCount += 10;
    }];
    [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
}

- (void)testLoading
{
    [HYQHUD showLoadingInView:self.view];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//    NSLog(@"1111");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
